<?php
class Offers {
    function viewAll() {
        $query = "select * from dt_offers order by o_id desc";
        $data = mysql_query($query);
        return $data;
    }

    function selectSingle($id) {
        $query = "select * from dt_offers where o_id = '$id'";
        $data = mysql_query($query);
        return $data;
    }

    function insert($label, $title, $price, $price_type, $content, $housing, $housing_link, $start_date, $end_date, $special, $active, 
            $random='0', $meta_title, $meta_desc, $meta_keys, $category, $mese_incluse, $orase_vizitate, $excursii_optionale, 
            $latitudine, $longitudine, $head_type = 'gallery', $o_small_desc) {
        $query = "insert into dt_offers (o_label, o_title, o_price, o_price_type, o_content, o_housing, o_housing_link, o_start_date, 
        o_end_date, o_special, o_active, o_random, o_meta_title, o_meta_desc, o_meta_keys, c_id, mese_incluse, orase_vizitate, 
        excursii_optionale, latitudine, longitudine, head_type, o_small_desc) values ('$label', '$title', '$price', '$price_type', 
        '$content', '$housing', '$housing_link', '$start_date', '$end_date', '$special', '$active', '$random', 
        '$meta_title', '$meta_desc', '$meta_keys', '$category', '$mese_incluse', '$orase_vizitate', '$excursii_optionale', '$latitudine', 
        '$longitudine', '$head_type', '$o_small_desc')";
        mysql_query($query);
    }

    function update($id, $label, $title, $price, $price_type, $content, $housing, $housing_link, $start_date, $end_date, $special, 
            $active, $random='0', $meta_title, $meta_desc, $meta_keys, $category, $mese_incluse, $orase_vizitate, $excursii_optionale, 
            $latitudine, $longitudine, $head_type = 'gallery', $o_small_desc) {
        $query = "update dt_offers set o_label = '$label', o_title = '$title', o_price = '$price', o_price_type = '$price_type', 
        o_content = '$content', o_housing = '$housing', o_housing_link = '$housing_link', o_start_date = '$start_date', 
        o_end_date = '$end_date', o_special = '$special', o_active = '$active', o_random = '$random', o_meta_title = '$meta_title', 
        o_meta_desc = '$meta_desc', o_meta_keys = '$meta_keys', c_id = '$category', mese_incluse = '$mese_incluse', 
        orase_vizitate = '$orase_vizitate', excursii_optionale = '$excursii_optionale', latitudine = '$latitudine', longitudine = '$longitudine', 
        head_type = '$head_type', o_small_desc = '$o_small_desc' where o_id = '$id'";
        mysql_query($query);
    }

    function delete($id) {
        $query = "delete from dt_offers where o_id = '$id'";
        mysql_query($query);
    }

    /* Offers pictures/video */
    function picViewForOffer($oid) {
        $query = "select * from dt_offers_photos where o_id = '$oid'";
        $data = mysql_query($query);
        return $data;
    }

    function picSelectSingle($id) {
        $query = "select * from dt_offers_photos where oImg_id = '$id'";
        $data = mysql_query($query);
        return $data;
    }

    function picInsert($file, $oid) {
        $query = "insert into dt_offers_photos (oImg_file, o_id) values ('$file', '$oid')";
        mysql_query($query);
    }

    function picDelete($id) {
        $query = "delete from dt_offers_photos where oImg_id = '$id'";
        mysql_query($query);
    }

    /*
     * Offers video
     */
    function vidViewForOffer($oid) {
        $query = "select * from dt_offers_video where o_id = '$oid'";
        $data = mysql_query($query);
        return $data;
    }

    function vidSelectSingle($id) {
        $query = "select * from dt_offers_video where oVid_id = '$id'";
        $data = mysql_query($query);
        return $data;
    }

    function vidInsert($file, $thumb, $oid) {
        $query = "insert into dt_offers_video (oVid_file, oVid_pic, o_id) values ('$file', '$thumb', '$oid')";
        mysql_query($query);
    }

    function vidDelete($id) {
        $query = "delete from dt_offers_video where oVid_id = '$id'";
        mysql_query($query);
    }
    /**
     * Offers MP3
     */
    function mp3ViewForOffer($oid) {
        $query = "select * from dt_offers_mp3 where o_id = '$oid'";
        $data = mysql_query($query);
        return $data;
    }

    function mp3SelectSingle($id) {
        $query = "select * from dt_offers_mp3 where id = '$id'";
        $data = mysql_query($query);
        return $data;
    }

    function mp3Insert($file, $oid) {
        $query = "insert into dt_offers_mp3 (file, o_id) values ('$file', '$oid')";
        mysql_query($query);
    }

    function mp3Delete($id) {
        $query = "delete from dt_offers_mp3 where id = '$id'";
        mysql_query($query);
    }
}
?>